-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: Initial support for grouped join pushdown #9032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9032 +/- ##
==========================================
+ Coverage 82.85% 83.14% +0.29%
==========================================
Files 222 225 +3
Lines 78828 80300 +1472
==========================================
+ Hits 65309 66767 +1458
- Misses 13519 13533 +14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
18417aa to
739fdc6
Compare
waralexrom
approved these changes
Jan 9, 2025
fe62c0f to
9440876
Compare
paveltiunov
approved these changes
Jan 13, 2025
…s a cube join condition
…mpty_tail) for empty joins in rules
They would be used later as a way to allow replacers to handle column from grouped subquery in join
Non-flatten rules will gain support for joins with grouped-grouped joins SQL generation support in WrappedSelect
9440876 to
e34feec
Compare
This was referenced Jan 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check List
Description of Changes Made (if issue reference is not provided)
With this
BaseQuerywill add grouped subqueries to SQL after subquery dimensions and join tree partswrapper_pullup_replacerinjoinposition ofwrapped_select, but still mostly with empty list inside. Notable exception is aggregation flattening - it is allowed to try to flatten aggregation into WrappedSelect with non-empty joins.wrapped_select_joinand over listWrappedSelectJoinslistgrouped_subqueriesin a context, it is used to track qualifiers of grouped subqueries, to allow rewriting of column expressions referencing grouped subquery with push-to-cube activeSELECT * FROM (ungrouped) JOIN (grouped);, this would allow to prefer representation without join, but with wrapper. Without this cost change join representation would have higherast_size_outside_wrappercomponent, but it is less important thenwrapper_nodes, so wrapper representation would be more expensive.WrappedSelectNodewill generate each grouped subquery separately, generate member expressions for join conditions and push all that to Cubepush_to_cube=falsequery as grouped, which is incorrect, as we may drop push-to-Cube when wrappingWrappedSelectwith another layer, even if innerWrappedSelectis projection. This is covered by check in SQL generation: onlyCubeScan(grouped=true)are allowed. This require new flag in wrapper replacers to fix.Supporting changes:
CubeScanWrappedSqlNodefromCubeScanWrapperNode. Both a logical plan nodes for now,Wrapperis generated during rewrites, andWrappedSqlstores SQL, generated generated duringevaluate_wrapped_sql__cubeJoinFieldjoin check to function, and make it stricter, onlyleft.__cubeJoinField = right.__cubeJoinFieldis allowedfind_column_by_aliasand__cubeJoinFieldjoin checkPushToCubeContextin SQL generation code, used to track everything necessary to generate SQL for push-to-Cube case. For now it contains ungroupedCubeScanNodethat whould be pushed into, and qualifiers and generated SQL for all grouped subqueries. Qualifiers are necessary to generate column expressions on top of ungrouped-grouped join.copy_value!macro, to extendcopy_flag!, allows to copy single value between different unary language variants